import React, { Component } from 'react'
import store from '../store'
import { add, minus, asyncMinus, asyncSetName } from '../store/actionCreator'
export default class Brother1 extends Component {
    state = {
        name: ''
    }
    add1 = () => {
        //   触发加操作 ACTION
        // store.dispatch({ type: 'ADD', payload: 3 })
        store.dispatch(add(5))
    }
    minus1 = () => {
        // store.dispatch(minus(4))
        store.dispatch(asyncMinus(4))

    }
    sure = () => {
        store.dispatch(asyncSetName(this.state.name))
    }
    render() {
        return (
            <div>
                <h2>brother1</h2>
                <br />
                <button onClick={this.add1}>加+</button>&nbsp;&nbsp;&nbsp;
                <button onClick={this.minus1}>减-</button>
                <br />
                <br />
                <br />
                <input type="text" value={this.state.name}
                    onChange={e => this.setState({ name: e.target.value })} />&nbsp;&nbsp;&nbsp;
                <button onClick={this.sure}>确定</button>
            </div>
        )
    }
}
